package fr.esgi.pages;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fr.esgi.donnees.Database;

/**
 * Servlet implementation class RelancerGroupeAleatoire
 */
public class RelancerGroupeAleatoire extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RelancerGroupeAleatoire() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String  projet=request.getParameter("projet");
		String promotion=request.getParameter("promotion");
		String  groupe=request.getParameter("groupe");
		String  nb=request.getParameter("nb");
		Database d=new Database();
		try {
			d.deleteEquipes(projet);
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		request.setAttribute("projet",projet);
		request.setAttribute("promotion",promotion);
		request.setAttribute("groupe",groupe);
		request.setAttribute("nb",nb);
		getServletContext().getRequestDispatcher("/jsp/pages/creationGroupeAleatoire.jsp").forward(request, response);
	}

}
